
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<head>
<title>Market place</title>
</head>

<body>
	<ui:composition>
		<p:panel id="promotionPanel"
			header="#{msgs.followingPromotionAvailable}" toggleable="true"
			collapsed="true" rendered="#{shoppingCartModel.promotions != null}"
			style="width:100%;font-size:0.9em">
			<p:dataTable value="#{shoppingCartModel.promotions}" var="promotion">
				<p:column headerText="#{msgs.promotionTitle}">
					<h:outputText value="#{promotion.titleLabel}"></h:outputText>
				</p:column>
				<p:column headerText="#{msgs.minimum}">
					<h:outputText value="#{promotion.minAmount}" style="color:red;font-size:1.2em"
						rendered="#{!promotion.isMinAmountValid}" >
						<f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" currencySymbol="$"></f:convertNumber>
						</h:outputText>
					<h:outputText value="#{promotion.minAmount}" style="green;color:green;font-size:1.2em"
						rendered="#{promotion.isMinAmountValid}" />
				</p:column>
				<p:column headerText="#{msgs.startDate}">
					<h:outputText value="#{promotion.startDate}" />
				</p:column>
				<p:column headerText="#{msgs.endDate}">
					<h:outputText value="#{promotion.endDate}" />
				</p:column>
				<p:column headerText="#{msgs.promotionCode}">					
					<h:panelGroup  rendered="#{promotion.isMinAmountValid}">
						<h:inputText value="#{promotion.userInputCode}"
							rendered="#{!promotion.isCodeValid}" size="5" />
						<p:commandButton value="#{msgs.activatePromotion}"
							actionListener="#{promotion.validCode}" ajax="true"
							update=":centerForm,:headerForm" rendered="#{!promotion.isCodeValid}"></p:commandButton>
						<h:outputText value="#{promotion.rewardRate}% #{msgs.creditReward}"
						rendered="#{promotion.isCodeValid}"></h:outputText>
					</h:panelGroup>					
				</p:column>
			</p:dataTable>
		</p:panel>
		<p:effect type="bounce" event="load" delay="400" for="promotionPanel"/>
	</ui:composition>
</body>

</html>


